import { cookie } from 'cookie.js';
import isClientApp from './isClientApp';

const TOKEN_KEY = "access_token";

export const getToken=()=>{
    const accessToken = isClientApp() ? localStorage.getItem(TOKEN_KEY) : cookie.get(TOKEN_KEY);
    return accessToken ? `Bearer ${accessToken}`:null;
}


export const setToken = (token) => {
    isClientApp() ? localStorage.setItem(TOKEN_KEY, token):cookie.set(TOKEN_KEY, token);
}


export const removeToken = () => {
    isClientApp() ? localStorage.removeItem(TOKEN_KEY):cookie.remove(TOKEN_KEY);
}